<?php
namespace Home\Controller;
class XinzuoController extends HomeController {
	public function index(){
		$xing=I('xing');
        $url="http://web.juhe.cn:8080/constellation/getAll?consName={$xing}&key=ce2ce0dfd802e7ff250cdf87fc66822e";
        $res=$this->curlSub($url);
        $this->assign('res',$res);
		$this->display();
	}
	private function curlSub($url,$post){
        //1.初始化
        $ch = curl_init();
        //2.相关设置
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if (stripos($url, "https://") !== false) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        }
        if($post != null){
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);    
        }
        //3.执行
        $res = curl_exec($ch);

        //当遇到错误的时候，我们可以将curl的错误打印出来
        if(curl_errno($ch) != 0){
            var_dump("错误号是".curl_errno($ch)."错误原因".curl_error($ch));
        }
        //4.关闭
        curl_close($ch);
        return json_decode($res,true);
    }
    /**
     * 微信api不支持中文转义的json结构
     * @param array $arr
     */
}